home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / QuickDraw / Restore Screen Cluts / ColorReset.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-09  |  13.0 KB  |  351 lines  |  [TEXT/MPS ]

  1. #ifndef __CLASSICIMAGE__
  2. #define __CLASSICIMAGE__
  3. /******************************************************************************\
  4. *
  5. * Apple Macintosh Developer Technical Support
  6. *
  7. * Main header file for the ClassicImage application
  8. *
  9. * Program: WorldImage
  10. * File:    WorldImage.h
  11. *
  12. * by:      Forrest Tanaka
  13. *
  14. * Copyright © 1988-1991 Apple Computer, Inc.
  15. * All rights reserved.
  16. *
  17. \******************************************************************************/
  18.     
  19.  
  20. /******************************************************************************\
  21. * Header Files
  22. \******************************************************************************/
  23.  
  24. #ifndef __STANDARDFILE__
  25. #include <StandardFile.h>
  26. #endif
  27.  
  28. #ifndef __WINDOWS__
  29. #include <Windows.h>
  30. #endif
  31.  
  32.  
  33. /******************************************************************************\
  34. * Constants
  35. \******************************************************************************/
  36.  
  37. #define kScrollBarWidth 16 /* Number of pixels wide a scroll bar is */
  38.  
  39. /* Alert types */
  40. #define kGenericAlert 0 /* Display a generic alert */
  41. #define kNoteAlert    1 /* Display the note alert */
  42. #define kCautionAlert 2 /* Display the caution alert */
  43. #define kStopAlert    3 /* Display the stop alert */
  44.  
  45. /* Alert button options */
  46. #define rOKAlertID       6010 /* Resource ID of OK alert */
  47. #define rOKCancelAlertID 6011 /* Resource ID of OK/Cancel alert */
  48. #define rSaveAlertID     6012 /* Resource ID of Save/Cancel/Don’t Save alert */
  49.  
  50. /* Button item numbers */
  51. #define kSaveButton       1 /* Item number of Save button */
  52. #define kCancelSaveButton 2 /* Item number of Cancel button for saves */
  53. #define kDontSaveButton   3 /* Item number of Don’t Save button */
  54.  
  55. /* Memory error message constants */
  56. #define rMemErrMessages    1000 /* Resource ID of memory error msg STR# */
  57. #define kMemErrAppOpenMsg  1    /* Not enough memory to open application */
  58. #define kMemErrOpenDocMsg  2    /* Not enough memory to open a document */
  59.  
  60. /* Resource error message constants */
  61. #define rResErrMessages     1001 /* Resource ID of resource err message STR# */
  62. #define kResErrAppDamageMsg 1    /* Application is damaged */
  63.  
  64. /* Miscellaneous error message constants */
  65. #define rMiscErrMessages   1002 /* Resource ID of misc. error message STR# */
  66. #define kMiscErrUnknownMsg 1    /* Unknown error */
  67. #define kMiscErrNoQTMsg    2    /* QuickTime not available */
  68. #define kMiscQuickTimeMsg  3    /* Some sort of QuickTime error */
  69.  
  70. /* File error message constants */
  71. #define rFileErrMessages   1003 /* Resource ID of file error message STR# */
  72. #define kFileErrDocOpenMsg 1    /* Document is already open elsewhere */
  73.  
  74.  
  75. /******************************************************************************\
  76. * Macros
  77. \******************************************************************************/
  78.  
  79. #ifdef applec
  80. #define topLeft(r) (*((Point *) &(r).top))
  81. #define botRight(r) (*((Point *) &(r).bottom))
  82. #endif
  83.  
  84. #define hiWord(a) ((short) (((unsigned long) a) >> 16L))
  85. #define loWord(a) ((short) ((unsigned long) a))
  86.  
  87.  
  88. /******************************************************************************\
  89. * Global Variables
  90. \******************************************************************************/
  91.  
  92. extern Boolean gQuitting;            /* True if user requested that app quit */
  93. extern Boolean gWereInFront;         /* True if this application is frontmost */
  94. extern Boolean gFixMenus;            /* True if menus need fixing */
  95. extern Boolean gHasAppleEvents;      /* True if Apple Events implemented */
  96. extern Boolean gHasCoolSF;           /* True if 7.0 Standard File available */
  97. extern ControlActionUPP gActionProc;
  98. extern QDBitsUPP        gQDBitsUPP;
  99. extern QDGetPicUPP      gQDGetPicUPP;
  100. extern QDPutPicUPP      gQDPutPicUPP;
  101.  
  102.  
  103. /******************************************************************************\
  104. * DoQuit - Handle Quit request from the user
  105. *
  106. * When the user requests that this application should quit, DoQuit is called to
  107. * perform the Quit command.  All open document windows and desk accessory
  108. * windows (only applicable before system software version 7.0) are closed and
  109. * the gQuitting global variable is set to true.
  110. \******************************************************************************/
  111.  
  112. void DoQuit(void);
  113.  
  114.  
  115. /******************************************************************************\
  116. * IsDAWindow - Test to see whether a window belongs to a DA or not
  117. *
  118. * If the window specified by aWindow belongs to a desk accessory, then
  119. * IsDAWindow returns true, otherwise it returns false.  If aWindow is nil, then
  120. * IsDAWindow returns false.
  121. \******************************************************************************/
  122.  
  123. Boolean IsDAWindow(
  124.     WindowPtr aWindow);
  125.  
  126.  
  127. /******************************************************************************\
  128. * DoUpdateEvt - Handle an update event for any window
  129. *
  130. * When an update event is received, DoUpdateEvt is called to handle the
  131. * redrawing of the window that caused the update event.  DoUpdateEvt determines
  132. * the kind of window that needs updating and calls the routine that handles that
  133. * kind of window to draw it.  The anEvent parameter contains the update event.
  134. \******************************************************************************/
  135.  
  136. void DoUpdateEvt(
  137.     EventRecord *anEvent);
  138.  
  139.  
  140. /******************************************************************************\
  141. * DoActivateEvt - Handle an activate event for any window
  142. *
  143. * DoActivateEvt is called when an active event is received for the window
  144. * specified by eventWind.  becomingActive is TRUE if the window is becoming
  145. * activated.  It’s FALSE if the window is becoming inactive.
  146. \******************************************************************************/
  147.  
  148. void DoActivateEvt(
  149.     WindowPtr eventWindow,
  150.     Boolean   becomingActive);
  151.  
  152.  
  153. /******************************************************************************\
  154. * ShowAlert - Show an alert
  155. *
  156. * This routine puts up a an alert with a specified message.  alertType specifies
  157. * which kind of icon to display in the upper-left corner of the alert.
  158. * kGenericAlert specifies that no icon should be displayed.  kNoteAlert
  159. * specifies that the note icon should be displayed.  kCautionAlert specifies
  160. * that the caution icon should be displayed.  kStopAlert specifies that the stop
  161. * icon should be displayed.
  162. *
  163. * buttonOption specifies what buttons should be offered.  rOKAlertID specifies
  164. * that only an OK button should be offered.  rOKCancelAlertID specifies that
  165. * both an OK and a Cancel button should be offered.
  166. *
  167. * messageClass specifies the STR# resource ID which contains the message to
  168. * display and messageIndex specifies the index (the first message is index 1)
  169. * into that STR# of the message to display.
  170. *
  171. * The alert window is placed into alert position on the screen containing most
  172. * of the window specified by parentWindow, or the main screen if parentWindow is
  173. * nil.
  174. \******************************************************************************/
  175.  
  176. short ShowAlert(
  177.     short alertType,
  178.     short buttonOption,
  179.     short messageClass,
  180.     short messageIndex);
  181.  
  182.  
  183. /******************************************************************************\
  184. * TrapExists - Determine whether a trap is implemented
  185. *
  186. * If the trap specified by theTrap is implemented, then TrapExists returns true.
  187. * Otherwise, false is returned.
  188. \******************************************************************************/
  189.  
  190. Boolean TrapExists(
  191.     short theTrap);
  192.  
  193.  
  194. /******************************************************************************\
  195. * FileSpecGet
  196. *
  197. \******************************************************************************/
  198.  
  199. Boolean FileSpecGet(
  200.     FileFilterProcPtr fileFilter,
  201.     short             numTypes,
  202.     SFTypeList        typeList,
  203.     StandardFileReply *retReply);
  204.  
  205.  
  206. /******************************************************************************\
  207. * ConvertOldToNewSFReply - Convert old SFReply record to new StandardFileReply record
  208. *
  209. * The old SFReply record passed in oldReply is converted to the new
  210. * StandardFileReply record that was introduced with system software version 7.0.
  211. * The resulting StandardFileReply record is returned in the newReply parameter.
  212. * If any errors occur, the error code is returned and newReply is untouched.
  213. *
  214. * The following conversions are done:
  215. *
  216. * StandardFileReply            SFReply
  217. * -----------------            -------
  218. * Boolean    sfGood        <-  Boolean good
  219. * Boolean    sfReplacing   <-  true if file exists, false if not
  220. * OSType     sfType        <-  OSType  fType
  221. * FSSpec     sfFile 
  222. *     vRefNum;             <-  real vRefnum from (short vRefNum)
  223. *     parID;               <-  real dirID from (short vRefNum)
  224. *     name;                <-  Str63   fName
  225. * ScriptCode sfScript      <-  iuSystemScript
  226. * short      sfFlags       <-  0
  227. * Boolean    sfIsFolder    <-  false
  228. * Boolean    sfIsVolume    <-  false
  229. * long       sfReserved1   <-  0
  230. * short      sfReserved2   <-  0
  231. *
  232. * The setting of sfScript to iuSystemScript I believe is incorrect, but I also
  233. * believe that it’s the best that can be done.  There’s no reliable way to tell
  234. * which script a user was using when he or she typed in the file name in the
  235. * Standard File dialog.  So, GUESS!
  236. \******************************************************************************/
  237.  
  238. OSErr ConvertOldToNewSFReply(
  239.     SFReply           *oldReply,
  240.     StandardFileReply *newReply);
  241.  
  242.  
  243. /******************************************************************************\
  244. * EqualFSSpec - Check equality of FSSpec records
  245. *
  246. * EqualFSSpec returns TRUE if the file specified by spec1 refers to the same
  247. * file as the one specified by spec2.  Otherwise, EqualFSSpec returns FALSE.
  248. \******************************************************************************/
  249.  
  250. Boolean EqualFSSpec(
  251.     FSSpecPtr spec0,
  252.     FSSpecPtr spec1);
  253.  
  254.  
  255. /******************************************************************************\
  256. * CmdPeriodEvent - Detect whether an event is a command-period
  257. *
  258. * This routine determines whether the event passed in anEvent was caused by the
  259. * user typing command-period.  If it was, then true is returned, otherwise false
  260. * is returned.
  261. \******************************************************************************/
  262.  
  263. Boolean CmdPeriodEvent(
  264.     EventRecord *anEvent);
  265.  
  266.  
  267. /******************************************************************************\
  268. * FakeButtonHit - Visually simulate the click of a button
  269. *
  270. * This routine is used to hilight a button for one-tenth of a second to visually
  271. * simulate the click of the mouse on the button passed in the buttonControl
  272. * parameter.  This is normally used when the Enter or Return key is pressed when
  273. * a dialog box is up.  The default button must be momentarily hilighted to show
  274. * the user what he or she actually did.
  275. \******************************************************************************/
  276.  
  277. void FakeButtonHit(
  278.     ControlHandle buttonControl);
  279.  
  280.  
  281. /******************************************************************************\
  282. * Public: CreateGrafPort
  283. *
  284. * Most of this code is very similar to the code in Macintosh Technical Note #41
  285. * “Drawing Into an Off-Screen BitMap.
  286. \******************************************************************************/
  287.  
  288. GrafPtr CreateGrafPort(
  289.     Rect *bounds);
  290.  
  291.  
  292. /******************************************************************************\
  293. * DisposeGrafPort
  294. *
  295. * DisposeGrafPort disposes of the GrafPort specified by doomedPort.  The visRgn,
  296. * clipRgn, bit image, and the GrafPort structure itself must all be disposed of.
  297. * ClosePort is called to dispose of the visRgn and clipRgn.  The bit image and
  298. * GrafPort itself are normal non-relocatable blocks of memory, so they’re just
  299. * disposed of through DisposePtr.
  300. \******************************************************************************/
  301.  
  302. void DisposeGrafPort(
  303.     GrafPtr doomedPort);
  304.  
  305.  
  306. /******************************************************************************\
  307. * NAME & SYNOPSIS:
  308. * RestoreColorsPalette: Restore all screens to the default color table
  309. *
  310. * PARAMETERS:
  311. * None
  312. *
  313. * DEFINITION:
  314. * RestoreColorsPalette sets the color tables of all screens to the default
  315. * colors by using the Palette Manager.  Direct-color screens and screens which
  316. * already have the default set of colors are unaffected.  It’s assumed that
  317. * Color QuickDraw is available, and 32-Bit QuickDraw 1.0 and/or system software
  318. * version 6.0.5 and beyond is available.
  319. *
  320. * RETURN VALUES:
  321. * None
  322. \******************************************************************************/
  323.  
  324. void RestoreColorsPalette(void);
  325.  
  326.  
  327. /******************************************************************************\
  328. * NAME & SYNOPSIS:
  329. * RestoreColorsSlam: Restore all screens to the default color table
  330. *
  331. * PARAMETERS:
  332. * None
  333. *
  334. * DEFINITION:
  335. * RestoreColorsSlam sets the color tables of all screens to the default colors
  336. * by using low-level calls.  All screens are redrawn when this routine is
  337. * called.  Also, if the color table has been changed and then RestoreColorsSlam
  338. * is called to reset them, all screens are still redrawn when the application
  339. * quits.  It’s assumed that Color QuickDraw is available, and 32-Bit QuickDraw
  340. * 1.0 and/or system software version 6.0.5 and beyond is available.
  341. *
  342. * RETURN VALUES:
  343. * None
  344. \******************************************************************************/
  345.  
  346. void RestoreColorsSlam(void);
  347.  
  348.  
  349. #endif
  350.